package com.iflytek.universitymanagement.prediect;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/api/analysis/predictions")
public class PredictionController {

    @Autowired
    private HBaseService hBaseService;

    // 根据学生姓名查询预测数据
    @GetMapping("/name/{name}")
    public ResponseEntity<List<PredictionResult>> getPredictionByName(@PathVariable String name) {
        try {
            List<PredictionResult> predictions = hBaseService.getPredictionByStudentName(name);
            return ResponseEntity.ok(predictions);
        } catch (IOException e) {
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
        }
    }
}
